package com.tuozixuan.atomic;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import com.google.common.base.Preconditions;

public class AtomicIntegerDemo00 {

	public static void main(String[] args) throws InterruptedException {

//		// 未指定初始值则默认为0
//		int value = 0;
//		
//
//		// 10个线程并发递增5000次
//		ExecutorService executorService = Executors.newFixedThreadPool(10);
//		int count = 5000;
//		CountDownLatch latch = new CountDownLatch(count);
//		for (int i = 0; i < count; i++) {
//			executorService.execute(() -> {
//				try {
//					value ++;
//				} finally {
//					latch.countDown();
//				}
//			});
//		}
//		latch.await();
//
//		// 等所有线程结束后再获取递增后的值
//		System.out.println("value:" + value);
//		Preconditions.checkArgument(value <= 5000);
//
//		executorService.shutdown();
	}

}
